<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<HEAD>
<LINK REL=STYLESHEET TYPE="text/css" HREF="../stylesheet.css" TITLE="Style">
<META NAME="GENERATOR" CONTENT="Java2HTML Version 1.5">
<TITLE>jminusminus.ParseException (Java2HTML)</TITLE>
</HEAD>
<BODY><TABLE id="Header" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td colspan="2" width="33%">&nbsp;</td>
<td align="center" colspan="2" width="33%">
<font size="4">ParseException.java</font>
</td>
<td align="right" colspan="2" width="33%">&nbsp;</td>
</tr>
</TABLE>
<pre ID="Classes">
<FONT ID="LN">1   </FONT><A NAME="1"></A><FONT ID="MultiLineComment">/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */</FONT>
<FONT ID="LN">2   </FONT><A NAME="2"></A><FONT ID="Package">package</FONT> jminusminus;
<FONT ID="LN">3   </FONT><A NAME="3"></A>
<FONT ID="LN">4   </FONT><A NAME="4"></A><FONT ID="FormalComment">/**
<FONT ID="LN">5   </FONT><A NAME="5"></A> * This exception is thrown when parse errors are encountered.
<FONT ID="LN">6   </FONT><A NAME="6"></A> * You can explicitly create objects of this exception type by
<FONT ID="LN">7   </FONT><A NAME="7"></A> * calling the method generateParseException in the generated
<FONT ID="LN">8   </FONT><A NAME="8"></A> * parser.
<FONT ID="LN">9   </FONT><A NAME="9"></A> *
<FONT ID="LN">10  </FONT><A NAME="10"></A> * You can modify this class to customize your error reporting
<FONT ID="LN">11  </FONT><A NAME="11"></A> * mechanisms so long as you retain the public fields.
<FONT ID="LN">12  </FONT><A NAME="12"></A> */</FONT>
<FONT ID="LN">13  </FONT><A NAME="13"></A><FONT ID="Public">public</FONT> <FONT ID="Class">class</FONT> ParseException <FONT ID="Extends">extends</FONT> Exception {
<FONT ID="LN">14  </FONT><A NAME="14"></A>
<FONT ID="LN">15  </FONT><A NAME="15"></A>  <FONT ID="FormalComment">/**
<FONT ID="LN">16  </FONT><A NAME="16"></A>   * This constructor is used by the method "generateParseException"
<FONT ID="LN">17  </FONT><A NAME="17"></A>   * in the generated parser.  Calling this constructor generates
<FONT ID="LN">18  </FONT><A NAME="18"></A>   * a new object of this type with the fields "currentToken",
<FONT ID="LN">19  </FONT><A NAME="19"></A>   * "expectedTokenSequences", and "tokenImage" set.  The boolean
<FONT ID="LN">20  </FONT><A NAME="20"></A>   * flag "specialConstructor" is also set to true to indicate that
<FONT ID="LN">21  </FONT><A NAME="21"></A>   * this constructor was used to create this object.
<FONT ID="LN">22  </FONT><A NAME="22"></A>   * This constructor calls its super class with the empty string
<FONT ID="LN">23  </FONT><A NAME="23"></A>   * to force the "toString" method of parent class "Throwable" to
<FONT ID="LN">24  </FONT><A NAME="24"></A>   * print the error message in the form:
<FONT ID="LN">25  </FONT><A NAME="25"></A>   *     ParseException: &lt;result of getMessage&gt;
<FONT ID="LN">26  </FONT><A NAME="26"></A>   */</FONT>
<FONT ID="LN">27  </FONT><A NAME="27"></A>  <FONT ID="Public">public</FONT> ParseException(<A HREF="../jminusminus/Token.java.html">Token</A> currentTokenVal,
<FONT ID="LN">28  </FONT><A NAME="28"></A>                        <FONT ID="Int">int</FONT>[][] expectedTokenSequencesVal,
<FONT ID="LN">29  </FONT><A NAME="29"></A>                        String[] tokenImageVal
<FONT ID="LN">30  </FONT><A NAME="30"></A>                       )
<FONT ID="LN">31  </FONT><A NAME="31"></A>  {
<FONT ID="LN">32  </FONT><A NAME="32"></A>    <FONT ID="Super">super</FONT>(<FONT ID="StringLiteral">""</FONT>);
<FONT ID="LN">33  </FONT><A NAME="33"></A>    specialConstructor = <FONT ID="True">true</FONT>;
<FONT ID="LN">34  </FONT><A NAME="34"></A>    currentToken = currentTokenVal;
<FONT ID="LN">35  </FONT><A NAME="35"></A>    expectedTokenSequences = expectedTokenSequencesVal;
<FONT ID="LN">36  </FONT><A NAME="36"></A>    tokenImage = tokenImageVal;
<FONT ID="LN">37  </FONT><A NAME="37"></A>  }
<FONT ID="LN">38  </FONT><A NAME="38"></A>
<FONT ID="LN">39  </FONT><A NAME="39"></A>  <FONT ID="FormalComment">/**
<FONT ID="LN">40  </FONT><A NAME="40"></A>   * The following constructors are for use by you for whatever
<FONT ID="LN">41  </FONT><A NAME="41"></A>   * purpose you can think of.  Constructing the exception in this
<FONT ID="LN">42  </FONT><A NAME="42"></A>   * manner makes the exception behave in the normal way - i.e., as
<FONT ID="LN">43  </FONT><A NAME="43"></A>   * documented in the class "Throwable".  The fields "errorToken",
<FONT ID="LN">44  </FONT><A NAME="44"></A>   * "expectedTokenSequences", and "tokenImage" do not contain
<FONT ID="LN">45  </FONT><A NAME="45"></A>   * relevant information.  The JavaCC generated code does not use
<FONT ID="LN">46  </FONT><A NAME="46"></A>   * these constructors.
<FONT ID="LN">47  </FONT><A NAME="47"></A>   */</FONT>
<FONT ID="LN">48  </FONT><A NAME="48"></A>
<FONT ID="LN">49  </FONT><A NAME="49"></A>  <FONT ID="Public">public</FONT> ParseException() {
<FONT ID="LN">50  </FONT><A NAME="50"></A>    <FONT ID="Super">super</FONT>();
<FONT ID="LN">51  </FONT><A NAME="51"></A>    specialConstructor = <FONT ID="False">false</FONT>;
<FONT ID="LN">52  </FONT><A NAME="52"></A>  }
<FONT ID="LN">53  </FONT><A NAME="53"></A>
<FONT ID="LN">54  </FONT><A NAME="54"></A>  <FONT ID="Public">public</FONT> ParseException(String message) {
<FONT ID="LN">55  </FONT><A NAME="55"></A>    <FONT ID="Super">super</FONT>(message);
<FONT ID="LN">56  </FONT><A NAME="56"></A>    specialConstructor = <FONT ID="False">false</FONT>;
<FONT ID="LN">57  </FONT><A NAME="57"></A>  }
<FONT ID="LN">58  </FONT><A NAME="58"></A>
<FONT ID="LN">59  </FONT><A NAME="59"></A>  <FONT ID="FormalComment">/**
<FONT ID="LN">60  </FONT><A NAME="60"></A>   * This variable determines which constructor was used to create
<FONT ID="LN">61  </FONT><A NAME="61"></A>   * this object and thereby affects the semantics of the
<FONT ID="LN">62  </FONT><A NAME="62"></A>   * "getMessage" method (see below).
<FONT ID="LN">63  </FONT><A NAME="63"></A>   */</FONT>
<FONT ID="LN">64  </FONT><A NAME="64"></A>  <FONT ID="Protected">protected</FONT> <FONT ID="Boolean">boolean</FONT> specialConstructor;
<FONT ID="LN">65  </FONT><A NAME="65"></A>
<FONT ID="LN">66  </FONT><A NAME="66"></A>  <FONT ID="FormalComment">/**
<FONT ID="LN">67  </FONT><A NAME="67"></A>   * This is the last token that has been consumed successfully.  If
<FONT ID="LN">68  </FONT><A NAME="68"></A>   * this object has been created due to a parse error, the token
<FONT ID="LN">69  </FONT><A NAME="69"></A>   * followng this token will (therefore) be the first error token.
<FONT ID="LN">70  </FONT><A NAME="70"></A>   */</FONT>
<FONT ID="LN">71  </FONT><A NAME="71"></A>  <FONT ID="Public">public</FONT> <A HREF="../jminusminus/Token.java.html">Token</A> currentToken;
<FONT ID="LN">72  </FONT><A NAME="72"></A>
<FONT ID="LN">73  </FONT><A NAME="73"></A>  <FONT ID="FormalComment">/**
<FONT ID="LN">74  </FONT><A NAME="74"></A>   * Each entry in this array is an array of integers.  Each array
<FONT ID="LN">75  </FONT><A NAME="75"></A>   * of integers represents a sequence of tokens (by their ordinal
<FONT ID="LN">76  </FONT><A NAME="76"></A>   * values) that is expected at this point of the parse.
<FONT ID="LN">77  </FONT><A NAME="77"></A>   */</FONT>
<FONT ID="LN">78  </FONT><A NAME="78"></A>  <FONT ID="Public">public</FONT> <FONT ID="Int">int</FONT>[][] expectedTokenSequences;
<FONT ID="LN">79  </FONT><A NAME="79"></A>
<FONT ID="LN">80  </FONT><A NAME="80"></A>  <FONT ID="FormalComment">/**
<FONT ID="LN">81  </FONT><A NAME="81"></A>   * This is a reference to the "tokenImage" array of the generated
<FONT ID="LN">82  </FONT><A NAME="82"></A>   * parser within which the parse error occurred.  This array is
<FONT ID="LN">83  </FONT><A NAME="83"></A>   * defined in the generated ...Constants interface.
<FONT ID="LN">84  </FONT><A NAME="84"></A>   */</FONT>
<FONT ID="LN">85  </FONT><A NAME="85"></A>  <FONT ID="Public">public</FONT> String[] tokenImage;
<FONT ID="LN">86  </FONT><A NAME="86"></A>
<FONT ID="LN">87  </FONT><A NAME="87"></A>  <FONT ID="FormalComment">/**
<FONT ID="LN">88  </FONT><A NAME="88"></A>   * This method has the standard behavior when this object has been
<FONT ID="LN">89  </FONT><A NAME="89"></A>   * created using the standard constructors.  Otherwise, it uses
<FONT ID="LN">90  </FONT><A NAME="90"></A>   * "currentToken" and "expectedTokenSequences" to generate a parse
<FONT ID="LN">91  </FONT><A NAME="91"></A>   * error message and returns it.  If this object has been created
<FONT ID="LN">92  </FONT><A NAME="92"></A>   * due to a parse error, and you do not catch it (it gets thrown
<FONT ID="LN">93  </FONT><A NAME="93"></A>   * from the parser), then this method is called during the printing
<FONT ID="LN">94  </FONT><A NAME="94"></A>   * of the final stack trace, and hence the correct error message
<FONT ID="LN">95  </FONT><A NAME="95"></A>   * gets displayed.
<FONT ID="LN">96  </FONT><A NAME="96"></A>   */</FONT>
<FONT ID="LN">97  </FONT><A NAME="97"></A>  <FONT ID="Public">public</FONT> String getMessage() {
<FONT ID="LN">98  </FONT><A NAME="98"></A>    <FONT ID="If">if</FONT> (!specialConstructor) {
<FONT ID="LN">99  </FONT><A NAME="99"></A>      <FONT ID="Return">return</FONT> <FONT ID="Super">super</FONT>.getMessage();
<FONT ID="LN">100 </FONT><A NAME="100"></A>    }
<FONT ID="LN">101 </FONT><A NAME="101"></A>    StringBuffer expected = <FONT ID="New">new</FONT> StringBuffer();
<FONT ID="LN">102 </FONT><A NAME="102"></A>    <FONT ID="Int">int</FONT> maxSize = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">103 </FONT><A NAME="103"></A>    <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>; i &lt; expectedTokenSequences.length; i++) {
<FONT ID="LN">104 </FONT><A NAME="104"></A>      <FONT ID="If">if</FONT> (maxSize &lt; expectedTokenSequences[i].length) {
<FONT ID="LN">105 </FONT><A NAME="105"></A>        maxSize = expectedTokenSequences[i].length;
<FONT ID="LN">106 </FONT><A NAME="106"></A>      }
<FONT ID="LN">107 </FONT><A NAME="107"></A>      <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> j = <FONT ID="IntegerLiteral">0</FONT>; j &lt; expectedTokenSequences[i].length; j++) {
<FONT ID="LN">108 </FONT><A NAME="108"></A>        expected.append(tokenImage[expectedTokenSequences[i][j]]).append(<FONT ID="StringLiteral">" "</FONT>);
<FONT ID="LN">109 </FONT><A NAME="109"></A>      }
<FONT ID="LN">110 </FONT><A NAME="110"></A>      <FONT ID="If">if</FONT> (expectedTokenSequences[i][expectedTokenSequences[i].length - <FONT ID="IntegerLiteral">1</FONT>] != <FONT ID="IntegerLiteral">0</FONT>) {
<FONT ID="LN">111 </FONT><A NAME="111"></A>        expected.append(<FONT ID="StringLiteral">"..."</FONT>);
<FONT ID="LN">112 </FONT><A NAME="112"></A>      }
<FONT ID="LN">113 </FONT><A NAME="113"></A>      expected.append(eol).append(<FONT ID="StringLiteral">"    "</FONT>);
<FONT ID="LN">114 </FONT><A NAME="114"></A>    }
<FONT ID="LN">115 </FONT><A NAME="115"></A>    String retval = <FONT ID="StringLiteral">"Encountered \""</FONT>;
<FONT ID="LN">116 </FONT><A NAME="116"></A>    <A HREF="../jminusminus/Token.java.html">Token</A> tok = currentToken.next;
<FONT ID="LN">117 </FONT><A NAME="117"></A>    <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>; i &lt; maxSize; i++) {
<FONT ID="LN">118 </FONT><A NAME="118"></A>      <FONT ID="If">if</FONT> (i != <FONT ID="IntegerLiteral">0</FONT>) retval += <FONT ID="StringLiteral">" "</FONT>;
<FONT ID="LN">119 </FONT><A NAME="119"></A>      <FONT ID="If">if</FONT> (tok.kind == <FONT ID="IntegerLiteral">0</FONT>) {
<FONT ID="LN">120 </FONT><A NAME="120"></A>        retval += tokenImage[<FONT ID="IntegerLiteral">0</FONT>];
<FONT ID="LN">121 </FONT><A NAME="121"></A>        <FONT ID="Break">break</FONT>;
<FONT ID="LN">122 </FONT><A NAME="122"></A>      }
<FONT ID="LN">123 </FONT><A NAME="123"></A>      retval += add_escapes(tok.image);
<FONT ID="LN">124 </FONT><A NAME="124"></A>      tok = tok.next; 
<FONT ID="LN">125 </FONT><A NAME="125"></A>    }
<FONT ID="LN">126 </FONT><A NAME="126"></A>    retval += <FONT ID="StringLiteral">"\" at line "</FONT> + currentToken.next.beginLine + <FONT ID="StringLiteral">", column "</FONT> + currentToken.next.beginColumn;
<FONT ID="LN">127 </FONT><A NAME="127"></A>    retval += <FONT ID="StringLiteral">"."</FONT> + eol;
<FONT ID="LN">128 </FONT><A NAME="128"></A>    <FONT ID="If">if</FONT> (expectedTokenSequences.length == <FONT ID="IntegerLiteral">1</FONT>) {
<FONT ID="LN">129 </FONT><A NAME="129"></A>      retval += <FONT ID="StringLiteral">"Was expecting:"</FONT> + eol + <FONT ID="StringLiteral">"    "</FONT>;
<FONT ID="LN">130 </FONT><A NAME="130"></A>    } <FONT ID="Else">else</FONT> {
<FONT ID="LN">131 </FONT><A NAME="131"></A>      retval += <FONT ID="StringLiteral">"Was expecting one of:"</FONT> + eol + <FONT ID="StringLiteral">"    "</FONT>;
<FONT ID="LN">132 </FONT><A NAME="132"></A>    }
<FONT ID="LN">133 </FONT><A NAME="133"></A>    retval += expected.toString();
<FONT ID="LN">134 </FONT><A NAME="134"></A>    <FONT ID="Return">return</FONT> retval;
<FONT ID="LN">135 </FONT><A NAME="135"></A>  }
<FONT ID="LN">136 </FONT><A NAME="136"></A>
<FONT ID="LN">137 </FONT><A NAME="137"></A>  <FONT ID="FormalComment">/**
<FONT ID="LN">138 </FONT><A NAME="138"></A>   * The end of line string for this machine.
<FONT ID="LN">139 </FONT><A NAME="139"></A>   */</FONT>
<FONT ID="LN">140 </FONT><A NAME="140"></A>  <FONT ID="Protected">protected</FONT> String eol = System.getProperty(<FONT ID="StringLiteral">"line.separator"</FONT>, <FONT ID="StringLiteral">"\n"</FONT>);
<FONT ID="LN">141 </FONT><A NAME="141"></A> 
<FONT ID="LN">142 </FONT><A NAME="142"></A>  <FONT ID="FormalComment">/**
<FONT ID="LN">143 </FONT><A NAME="143"></A>   * Used to convert raw characters to their escaped version
<FONT ID="LN">144 </FONT><A NAME="144"></A>   * when these raw version cannot be used as part of an ASCII
<FONT ID="LN">145 </FONT><A NAME="145"></A>   * string literal.
<FONT ID="LN">146 </FONT><A NAME="146"></A>   */</FONT>
<FONT ID="LN">147 </FONT><A NAME="147"></A>  <FONT ID="Protected">protected</FONT> String add_escapes(String str) {
<FONT ID="LN">148 </FONT><A NAME="148"></A>      StringBuffer retval = <FONT ID="New">new</FONT> StringBuffer();
<FONT ID="LN">149 </FONT><A NAME="149"></A>      <FONT ID="Char">char</FONT> ch;
<FONT ID="LN">150 </FONT><A NAME="150"></A>      <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>; i &lt; str.length(); i++) {
<FONT ID="LN">151 </FONT><A NAME="151"></A>        <FONT ID="Switch">switch</FONT> (str.charAt(i))
<FONT ID="LN">152 </FONT><A NAME="152"></A>        {
<FONT ID="LN">153 </FONT><A NAME="153"></A>           <FONT ID="Case">case</FONT> <FONT ID="IntegerLiteral">0</FONT> :
<FONT ID="LN">154 </FONT><A NAME="154"></A>              <FONT ID="Continue">continue</FONT>;
<FONT ID="LN">155 </FONT><A NAME="155"></A>           <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'\b'</FONT>:
<FONT ID="LN">156 </FONT><A NAME="156"></A>              retval.append(<FONT ID="StringLiteral">"\\b"</FONT>);
<FONT ID="LN">157 </FONT><A NAME="157"></A>              <FONT ID="Continue">continue</FONT>;
<FONT ID="LN">158 </FONT><A NAME="158"></A>           <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'\t'</FONT>:
<FONT ID="LN">159 </FONT><A NAME="159"></A>              retval.append(<FONT ID="StringLiteral">"\\t"</FONT>);
<FONT ID="LN">160 </FONT><A NAME="160"></A>              <FONT ID="Continue">continue</FONT>;
<FONT ID="LN">161 </FONT><A NAME="161"></A>           <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'\n'</FONT>:
<FONT ID="LN">162 </FONT><A NAME="162"></A>              retval.append(<FONT ID="StringLiteral">"\\n"</FONT>);
<FONT ID="LN">163 </FONT><A NAME="163"></A>              <FONT ID="Continue">continue</FONT>;
<FONT ID="LN">164 </FONT><A NAME="164"></A>           <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'\f'</FONT>:
<FONT ID="LN">165 </FONT><A NAME="165"></A>              retval.append(<FONT ID="StringLiteral">"\\f"</FONT>);
<FONT ID="LN">166 </FONT><A NAME="166"></A>              <FONT ID="Continue">continue</FONT>;
<FONT ID="LN">167 </FONT><A NAME="167"></A>           <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'\r'</FONT>:
<FONT ID="LN">168 </FONT><A NAME="168"></A>              retval.append(<FONT ID="StringLiteral">"\\r"</FONT>);
<FONT ID="LN">169 </FONT><A NAME="169"></A>              <FONT ID="Continue">continue</FONT>;
<FONT ID="LN">170 </FONT><A NAME="170"></A>           <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'\"'</FONT>:
<FONT ID="LN">171 </FONT><A NAME="171"></A>              retval.append(<FONT ID="StringLiteral">"\\\""</FONT>);
<FONT ID="LN">172 </FONT><A NAME="172"></A>              <FONT ID="Continue">continue</FONT>;
<FONT ID="LN">173 </FONT><A NAME="173"></A>           <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'\''</FONT>:
<FONT ID="LN">174 </FONT><A NAME="174"></A>              retval.append(<FONT ID="StringLiteral">"\\\'"</FONT>);
<FONT ID="LN">175 </FONT><A NAME="175"></A>              <FONT ID="Continue">continue</FONT>;
<FONT ID="LN">176 </FONT><A NAME="176"></A>           <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'\\'</FONT>:
<FONT ID="LN">177 </FONT><A NAME="177"></A>              retval.append(<FONT ID="StringLiteral">"\\\\"</FONT>);
<FONT ID="LN">178 </FONT><A NAME="178"></A>              <FONT ID="Continue">continue</FONT>;
<FONT ID="LN">179 </FONT><A NAME="179"></A>           <FONT ID="Default">default</FONT>:
<FONT ID="LN">180 </FONT><A NAME="180"></A>              <FONT ID="If">if</FONT> ((ch = str.charAt(i)) &lt; <FONT ID="IntegerLiteral">0x20</FONT> || ch &gt; <FONT ID="IntegerLiteral">0x7e</FONT>) {
<FONT ID="LN">181 </FONT><A NAME="181"></A>                 String s = <FONT ID="StringLiteral">"0000"</FONT> + Integer.toString(ch, <FONT ID="IntegerLiteral">16</FONT>);
<FONT ID="LN">182 </FONT><A NAME="182"></A>                 retval.append(<FONT ID="StringLiteral">"\\u"</FONT> + s.substring(s.length() - <FONT ID="IntegerLiteral">4</FONT>, s.length()));
<FONT ID="LN">183 </FONT><A NAME="183"></A>              } <FONT ID="Else">else</FONT> {
<FONT ID="LN">184 </FONT><A NAME="184"></A>                 retval.append(ch);
<FONT ID="LN">185 </FONT><A NAME="185"></A>              }
<FONT ID="LN">186 </FONT><A NAME="186"></A>              <FONT ID="Continue">continue</FONT>;
<FONT ID="LN">187 </FONT><A NAME="187"></A>        }
<FONT ID="LN">188 </FONT><A NAME="188"></A>      }
<FONT ID="LN">189 </FONT><A NAME="189"></A>      <FONT ID="Return">return</FONT> retval.toString();
<FONT ID="LN">190 </FONT><A NAME="190"></A>   }
<FONT ID="LN">191 </FONT><A NAME="191"></A>
<FONT ID="LN">192 </FONT><A NAME="192"></A>}
<FONT ID="LN">193 </FONT><A NAME="193"></A></pre>
</BODY>
</HTML>